iT邦幫忙

2022 iThome 鐵人賽

DAY 7
0
自我挑戰組

Identity Management 系列 第 7

07 - OAuth (1) Roles and Grant Types

  • 分享至 

  • xImage
  •  

OAuth 是一個針對存取授權的開放標準,也就是針對先前提到的 authorization 所設計的標準。

OAuth 開始於 2006 年,於 2009 年推出 1.0 的標準,並在 2013 年推出 2.0 版本(以下提到的皆是 2.0 當中的內容)

Roles

在 OAuth 當中,主要有四個角色

1. Resource Server

存放資源的系統。在之後的例子當中,就是需要「授權」他人存取的系統

2. Resource Owner

資源的擁有者

3. Client

一個想要存取資源、並要求 resource server「授權」的系統或應用程式

4. Authorization Server

一個受到 resource server 信任,並被 resource server 用來「授權」client 的系統。

之後的例子當中的使用者情境,基本上就會是

client 要求存取 resource owner 存放在 resource server 當中的資源,因此 resource server 透過(委託) authorization server 來授權 client


Client Types

在 OAuth 2.0 當中的 client 有兩種類型

  • 1. confidential client - 擁有受保護的 server 可以存放重要的 secret
  • 2. public client - 譬如 SPA 或是 native app,無法安全存放重要的 secret

Grant Types

OAuth 2.0 定義了四種授權方式,分別是

  • Authorization code grant
  • Implicit grant
  • Resource owner password credentials grant
  • Client credential grant

1. Authorization code grant

這是最常見也是最安全的授權方式,適用於 confidential client(譬如有 backend 的應用程式)

2. Implicit grant

適用於 public client(譬如 SPA),和 Authorization code grant 相比之下相對簡化,當然安全性就沒有這沒高

3. Resource owner password credentials grant

在這個授權方式下,resource owner 向 client 直些提供 credential,然後 client 再向 authorization server 取得 access token。而上面提到的兩個授權方式則是 resource owner 向 resource serbver 提供 credential。這種授權方式有其風險,除非上面兩種授權方式無法使用,同時 resource owner 高度信任 client

4. Client credentitial grant

最後一種授權方式適用於沒有前端的應用程式(譬如 API server),這時候授權的對象其實直接是 client 應用程式,因為這種情況下使用者(resource owner)並不會參與相關的互動。


接下來我們會一起來看這四種授權方式的流程與細節


上一篇
06 - Evolution of identity management
下一篇
08 - OAuth (2) Authorization code grant
系列文
Identity Management 31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言